﻿using System;
using System.Windows;
using AutoMapper;
using Microsoft.Extensions.DependencyInjection;
using Prism.Ioc;
using Prism.Modularity;
using Prism.Regions;
using YJTTool.Configure;
using YJTTool.CustomerInfo;
using YJTTool.CustomerInfo.Profiles;
using YJTTool.CustomerInfo.Views;
using YJTTool.DrugControls;
using YJTTool.DrugControls.Views;
using YJTTool.Handy.Views;

namespace YJTTool.Handy
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App
    {
        public static IServiceProvider ServiceProvider { get; private set; }
        private IRegionManager _regionManager;
        protected override Window CreateShell()
        {
            return Container.Resolve<LoginView>();
        }

        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
            var regionManager = Container.Resolve<IRegionManager>();
            regionManager.RegisterViewWithRegion("ContentRegion", typeof(HomePage));
            containerRegistry.RegisterSingleton<IMapper>(provider =>
            {
                var config = new MapperConfiguration(cfg =>
                {
                    cfg.AddProfile<TelematicsMappingProfile>();
                });
                config.AssertConfigurationIsValid();
                return config.CreateMapper();
            });
        }

        protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
        {
            moduleCatalog.AddModule<CustomerInfoModule>();
            moduleCatalog.AddModule<DrugControlsModule>();
            moduleCatalog.AddModule<ConfigureModule>();
        }
    }
}
